package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppFunctionalService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppFunctionalCreateValidate;
import com.mdd.admin.validate.yylq.TAppFunctionalSearchValidate;
import com.mdd.admin.validate.yylq.TAppFunctionalUpdateValidate;
import com.mdd.admin.vo.yylq.TAppFunctionalDetailVo;
import com.mdd.admin.vo.yylq.TAppFunctionalListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@ApiIgnore
@RestController
@RequestMapping("/adminapi/yylq/functional")
@Api(tags = "羊羊领企---领企管家---功能模块管理")
public class TAppFunctionalController {

    @Resource
    ITAppFunctionalService iTAppFunctionalService;

    @GetMapping("/list")
    @ApiOperation(value="领企管家---功能模块列表")
    public AjaxResult<PageResult<TAppFunctionalListedVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated TAppFunctionalSearchValidate searchValidate) {
        PageResult<TAppFunctionalListedVo> list = iTAppFunctionalService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="领企管家---功能模块详情")
    public AjaxResult<TAppFunctionalDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppFunctionalDetailVo detail = iTAppFunctionalService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "领企管家---功能模块新增")
    @PostMapping("/add")
    @ApiOperation(value="领企管家---功能模块新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppFunctionalCreateValidate createValidate) {
        iTAppFunctionalService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "领企管家---功能模块编辑")
    @PostMapping("/edit")
    @ApiOperation(value="领企管家---功能模块编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppFunctionalUpdateValidate updateValidate) {
        iTAppFunctionalService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "领企管家---功能模块删除")
    @PostMapping("/del")
    @ApiOperation(value="领企管家---功能模块删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppFunctionalService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
